<%@page import="model.person.Person"%>
<%@page import="utils.TextUtils"%>
<%@page import="org.springframework.web.bind.annotation.RequestParam"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<jsp:include page="../header.jsp" />

<center>
	<u>Lista Ostatnich Twoich Postów I Postów Twoich Znajomych</u>
</center>
<br><br><br>

<c:if test="${listOfPosts.size() eq 0}">
	Nie ma postów
</c:if>

<table>

	<c:forEach var="post" items="${listOfPosts}" end="10" step="1">
		<tr>
			<td align="left"><c:choose>
					<c:when test="${post.getSourcePerson().getAccountID() eq loggedUser.getAccountID()}">
						<strong>Ja</strong>
					</c:when>
					<c:otherwise>
						<strong>${post.getSourcePerson().getName()} ${post.getSourcePerson().getSurname()}</strong>
					</c:otherwise>
				</c:choose> <i> do </i> <c:choose>
					<c:when test="${post.getDestinationPerson().getAccountID() eq loggedUser.getAccountID()}">
						<strong>Ja</strong>
					</c:when>
					<c:otherwise>
						<strong>${post.getDestinationPerson().getName()} ${post.getDestinationPerson().getSurname()}</strong>
					</c:otherwise>
				</c:choose></td>
			<td align="right">${post.getCreatedDateString()}</td>
		</tr>
		<tr height="200">
			<!-- td>Treść:</td -->
			<td width="20%" align="center" valign="baseline" colspan="2">${post.getPostContent()}</td>
		</tr>
		<tr>

			<td align="right" colspan="2"><c:if test="${ loggedUser.getAccountID() eq post.getDestinationPerson().getAccountID() or loggedUser.getAccountID() eq post.getSourcePerson().getAccountID() or loggedUser.hasRole('admin')}">
					<a href="profile.html?id=${post.getDestinationPerson().getAccountID()}&deleteId=${post.getId()}">Usuń</a>
				</c:if></td>
		</tr>

		<tr height="30">
			<td colspan="2">
				<hr>
			</td>
		</tr>
	</c:forEach>
</table>

<jsp:include page="../footer.jsp" />